package com.Jin.service;

import com.Jin.dao.UserDao;
import com.Jin.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService{

    @Autowired
    private UserDao userDao;

    //登录
    @Override
    public User login(String account, String password) {
        User user = userDao.selectUser(account,password);
        return user;
    }

    //新增用户
    @Override
    public boolean addUser(User user) {
        int n = userDao.saveUser(user);
        return n>0;
    }

    //更新用户信息
    @Override
    public boolean updateUser(User user) {
        int n = userDao.updateUser(user);
        return n>0;
    }

    //更新密码
    @Override
    public boolean updateUserPassword(String account, String password) {
        int n = userDao.updateUserPassword(account, password);
        return n>0;
    }

    //查询用户
    @Override
    public User selectUsers(String account) {
        User user = userDao.selectUsers(account);
        return user;
    }

    //查询所有用户
    @Override
    public List<User> selectAllUser() {
        List<User> userList = userDao.selectAllUser();
        return userList;
    }
}
